<?php

set_include_path('.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../application/default/models/' . PATH_SEPARATOR . get_include_path());

//require_once 'Zend/Loader.php';
require_once 'Zend/Controller/Front.php';
require_once 'Zend/Config/Ini.php';
require_once 'Zend/Registry.php';
require_once 'Zend/Db.php';
require_once 'Zend/Db/Table/Abstract.php';
require_once '../application/layered/Plugin.php';

// Set up autoload.
//Zend_Loader::registerAutoload();

// Prepare the front controller. 
$front = Zend_Controller_Front::getInstance();

// load configurations
$config = new Zend_Config_Ini('../config/main.ini', null, true);
Zend_Registry::set('config', $config);

// configure database
$db = Zend_Db::factory($config->database->adapter, $config->database);
Zend_Registry::set('db', $db);
Zend_Db_Table_Abstract::setDefaultAdapter($db);

$front->registerPlugin(new Layered_Plugin());

// set module directory
$front->addModuleDirectory('../application');

// Dispatch the request using the front controller. 
$front->dispatch();
